#include "client.h"

int connectTcp(char *ip,char *port){
    int sockfd = socket(AF_INET,SOCK_STREAM,0);
    int flag=1;
    setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&flag,sizeof(flag));
    struct sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_port = htons(atoi(port));
    addr.sin_addr.s_addr = inet_addr(ip);
    printf("client 准备连接。\n");
    int ret = connect(sockfd,(struct sockaddr *)&addr,sizeof(addr));
    printf("connect aftre.\n");
    ERROR_CHECK(ret,-1,"connect");
    return sockfd;
}
